package com.woniu.market_stall_web.controller;

import com.woniu.market_stall_web.entity.User;
import com.woniu.market_stall_web.service.StallAuctionService;
import com.woniu.market_stall_web.vo.StallAuctionVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/auction")
public class SatallAuctionController {
    @Autowired
    StallAuctionService stallAuctionService;
    @RequestMapping("/all")
    public String all(Map map, HttpSession httpSession){
        User userInfo = (User) httpSession.getAttribute("userInfo");
        List<StallAuctionVo> list = stallAuctionService.queryAll(userInfo.getUsername());
        map.put("bidList",list);
        System.out.println(list);
        return "bid";
    }
    @RequestMapping("/bidding")
    public String bidding(Map map, HttpSession httpSession){
        User userInfo = (User) httpSession.getAttribute("userInfo");
        List<StallAuctionVo> list = stallAuctionService.queryBidding(userInfo.getUsername());
        map.put("biddingList",list);
        return "bidding";
    }


    @RequestMapping("/win")
    public String win(Map map, HttpSession httpSession){
        User userInfo = (User) httpSession.getAttribute("userInfo");
        List<StallAuctionVo> list = stallAuctionService.querywin(userInfo.getUsername());
        map.put("biddingList",list);
        return "win";
    }
}
